<template>
  <div class="resume-detail-skill info-group">
    <div class="info-group-title">
      专业技能<span
        class="info-group-action"
        type="primary"
        @click="$emit('edit')"
        ><SvgIcon name="xinjian2" />添加专业技能</span
      >
    </div>
    <div class="info-group-content">
      <div class="skill-item" v-for="(item, index) in data" :key="index">
        <div class="skill-name">{{ item.skillName }}</div>
        <div class="skill-item-bottom">
          <div class="skill-time">使用时长：{{ item.time }}</div>
          <div class="skill-proficiency-chart">
            <div
              class="skill-proficiency-value"
              :class="'level-' + item.proficiency"
            ></div>
          </div>
          <div class="skill-proficiency-name">{{ item.proficiencyName }}</div>
        </div>
        <div class="skill-info-action">
          <span type="primary" @click="handleRemove(item.id)"
            ><SvgIcon name="shanchu" />删除</span
          >
          <span type="primary" @click="$emit('edit', item)"
            ><SvgIcon name="xiugai1" />编辑</span
          >
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { deleteSkill } from 'services/student/resume'
export default {
  name: 'ResumeDetailSkill',
  props: {
    data: {
      type: Array,
      default: () => []
    }
  },
  methods: {
    async handleRemove(id) {
      try {
        await this.$confirm(
          this.$t('tip.removeTip'),
          this.$t('tip.systemTip'),
          {
            type: 'warning'
          }
        )
        const ids = [id]
        await deleteSkill(ids)
        this.$bus.$emit('resume-update')
      } catch {}
    }
  }
}
</script>

<style lang="scss">
@import 'styles/common.scss';
.resume-detail-skill {
  .skill-item {
    height: 92px;
    margin-left: -10px;
    padding-left: 10px;
    padding-top: 20px;
    position: relative;
    &:hover {
      background-color: $colorBG2;
      .skill-info-action {
        display: block;
      }
    }
    .skill-info-action {
      display: none;
      position: absolute;
      top: 0.24rem;
      right: 0.35rem;
      color: $colorPrimary;
      cursor: pointer;
      .svg-icon {
        margin-left: 20px;
        margin-right: 10px;
      }
    }
    .skill-name {
      font-size: 16px;
      color: $colorText1;
    }
    .skill-item-bottom {
      margin-top: 0.2rem;
      display: flex;
      align-items: center;
      padding-right: 2rem;
      .skill-time {
        width: 150px;
      }
      .skill-proficiency-chart {
        flex: 1;
        height: 14px;
        background-color: #ddd;
        border-radius: 7px;
        overflow: hidden;
        .skill-proficiency-value {
          background-color: $colorPrimary;
          height: 100%;
          &.level-1 {
            width: 30%;
          }
          &.level-3 {
            width: 60%;
          }
          &.level-5 {
            width: 90%;
          }
        }
      }
      .skill-proficiency-name {
        margin-left: 0.33rem;
        width: 100px;
      }
    }
    .skill-edit {
      position: absolute;
      top: 0;
      right: 0;
      color: $colorPrimary;
      cursor: pointer;
      .svg-icon {
        margin-right: 10px;
      }
    }
  }
}
</style>
